#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; tool for string



S(str, old, new:="") {  ; replace string, re not supported
    Return StrReplace(str, old, new)
}



S_EmptyIs(v) {
    /*
    str is empty: empty - True; not - False
    */
    v := R(v, "[\s\r\n\t ]", "")

    if (v == "") {
        Return True
    }
    Return False
}



S_EmptyNot(v) {
    Return !S_EmptyIs(v)
}



S_EmptyDefault(v, t) {
    ; str is empty v, else t
    Return S_EmptyNot(v) ? v : t
}



S_EmptyClip(v:="") {
    ; donot abuse this
    Return S_EmptyIs(v) ? C() : v
}



S_Blank(rows:="") {
    rows := R(rows, "(^[`r`n]+)|([`r`n]+$)")  ; del line in head/tail
    rows := R(rows , "[`r`n]{3,}", "`n`n")  ; del multi line
    rows := R(rows, "`t", "    ")  ; Tab > Space
    Return rows
}



S_Find(str, find, caseSensitive:=False) { ; find sub in str, return 0-not found
    Return InStr(str, find, caseSensitive)
}



S_Replace(str, old, new:="") {  ; no support re
    Return StrReplace(str, old, new)
}



S_Split(row, split:="`n") {  ; str split to array
    Return StrSplit(row, split)
}
